import { Body, Controller, HttpCode, Post, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiTags } from '@nestjs/swagger';
import { AuthService, LoginInfo, modifyLoginInfo } from './auth.service';

@Controller('auth')
@ApiTags('登录认证模块')
export class AuthController {
  constructor(private readonly authService: AuthService) { }
  // 登录接口
  @UseGuards(AuthGuard('local'))
  @Post('login')
  async login(@Body() req: LoginInfo) {
    return this.authService.login(req);
  }

  @HttpCode(200)
  @Post('register')
  async register(@Body() req: LoginInfo) {
    return this.authService.register(req);
  }

  @Post('modifyPwd')
  async modifyPwd(@Body() req: modifyLoginInfo) {
    return this.authService.modifyPwd(req);
  }
}
